package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.apsworkdetail.*;
import com.zmj.sy.mom.srv.aps.bean.vo.base.*;
import com.zmj.sy.mom.srv.aps.service.ApsWorkDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@Api(tags = "APS工单明细")
@RestController
@RequestMapping("/apsWorkDetail")
public class ApsWorkDetailController {

    private final ApsWorkDetailService apsWorkDetailService;

    @ApiOperation("工单明细")
    @GetMapping("/list")
    public BaseListResVo<ApsWorkDetailListResVo> list(BaseIdReqVo reqVo) {
        return apsWorkDetailService.list(reqVo);
    }

    @ApiOperation("总排产列表")
    @GetMapping("/pubList")
    public BasePageResVo<ApsWorkDetailPubListResVo> pubList(ApsWorkDetailPubListReqVo reqVo) {
        return apsWorkDetailService.pubList(reqVo);
    }

    @ApiOperation("修改计划任务工作组")
    @PostMapping("/updateDetailTask")
    public BaseResVo updateDetailTask(WorkDetailTaskReqVo reqVo) {
        apsWorkDetailService.updateDetailTask(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("修改计划工作组")
    @PostMapping("/detailGroup")
    public BaseResVo detailGroup(@RequestBody WorkDetailTaskReqVo reqVo) {
        apsWorkDetailService.detailGroup(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("组件下零件及数量")
    @GetMapping("/getPartsCount")
    public BaseListResVo<AssemPartsCountsResVo> getPartsCount(AssemPartsCountsReqVo reqVo) {
        return apsWorkDetailService.getPartsCount(reqVo);
    }

    @ApiOperation("获取日工组计划")
    @PostMapping("/dateMesWorkDetail")
    public BaseListResVo<AssemWorkDetailResVo> dateMesWorkDetail(@RequestBody @Validated MesWorkDetailReqVo reqVo) {
        return apsWorkDetailService.dateMesWorkDetail(reqVo);
    }

    @ApiOperation("生成日工组计划")
    @PostMapping("/makeMesWorkDetail")
    public BaseResVo makeMesWorkDetail(String date) {
        return apsWorkDetailService.makeMesWorkDetail(date);
    }

    @ApiOperation("查询当前工作组")
    @PostMapping("/getDetailGroup")
    public WorkDetailGroupResVo getDetailGroup(@RequestBody @Validated MesWorkDetailReqVo reqVo) {
        return  apsWorkDetailService.getDetailGroup(reqVo);
    }

    @ApiOperation("查询日计划数量")
    @PostMapping("/getDetailCount")
    public Result<Integer> getDetailCount(@RequestBody @Validated MesWorkDetailCountReqVo reqVo) {
        return  apsWorkDetailService.getDetailCount(reqVo);
    }

    @ApiOperation("更新当前工作组")
    @PostMapping("/updateDetailGroup")
    public BaseResVo updateDetailGroup(@RequestBody @Validated MesWorkDetailReqVo reqVo) {
        return  apsWorkDetailService.updateDetailGroup(reqVo);
    }

  /*  @ApiOperation("下发当日计划")
    @PostMapping("/createWorkDetail")
    public BaseResVo createWorkDetail(@RequestBody  AssemWorkShiftReqVO reqVo) {
        return  apsWorkDetailService.createWorkDetail(reqVo);
    }*/

    @ApiOperation("更新当日计划")
    @PostMapping("/updateWorkDetail")
    public BaseResVo updateWorkDetail(@RequestBody  AssemUpdateWorkShiftReqVO reqVo) {
        return  apsWorkDetailService.updateWorkDetail(reqVo);
    }

    @ApiOperation("pda获取当日计划")
    @GetMapping ("/pdaDateMesWorkDetail")
    public Result<List<PdaWorkDetailResVo>> pdaDateMesWorkDetail(@ApiParam(value = "工位或工作组编号", required = true) String stationCode, @ApiParam (value = "班次  0 全天  1 白班  2 夜班", required = true) Integer shiftNum) {
        return  apsWorkDetailService.pdaDateMesWorkDetailMk(stationCode,shiftNum);
    }

    @ApiOperation("获取待产的订单列表")
    @GetMapping ("/construnctNoList")
    public Result<List<String>> construnctNoList() {
        return  apsWorkDetailService.construnctNoList();
    }

}
